package dao;

import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;


import core.Dictionary;
import db.DbController;

public class DbDictionaries {
  
    public static int insert(int fromID, int toID, String dictURL) {
    	
    	Connection cnn = null;
        CallableStatement cstat = null;
        
        try {
            cnn = DbController.getConnection();
            cstat = cnn.prepareCall("{call m_dictionaries_insert(?,?,?)}");
            cstat.setInt(1, fromID);
            cstat.setInt(2, toID);
            cstat.setString(3, dictURL);
            
            return cstat.executeUpdate();
        }
        
        catch (SQLException e) {
			// TODO: handle exception
        	return 0;
		}         	
    }
    
    public static int update(int dictID, int delCount) {
    	Connection cnn = null;
        CallableStatement cstat = null;
        
        try {
            cnn = DbController.getConnection();
            cstat = cnn.prepareCall("{call update_dictionaries_delcount(?,?)}");
            cstat.setInt(1, dictID);
            cstat.setInt(2, delCount);
            
            return cstat.executeUpdate();
        }
        
        catch (SQLException e) {
			// TODO: handle exception
        	return 0;
		}       
    }
    
    public static int delete(int dictID) {
    	
    }
    
    public static ResultSet getDelCount(int fromID, int toID) {
    	
    }

    public static ResultSet getDictionaries() {
    	
    }

    public static ResultSet getDictID(int langID) {
    	
    }
}